{% import "TopxiaWebBundle::macro.html.twig" as web_macro %}
<li id="post-{{ post.id }}" data-user-id="{{ author.id }}" class="thread-post thread-post-{{ post.id }} media media-comment user-id-{{author.id}}">
  <div class="media-left">
    {{ web_macro.user_avatar(author, 'user-avatar', 'avatar-sm', true) }}
  </div>

  <div class="media-body">
    <div class="metas title">
      {% include 'TopxiaWebBundle:Thread:post-manage-menu.html.twig' %}
      <a href="{{ path('user_show', {id:author.id}) }}" class="nickname">{{ author.nickname }}</a>
      <span class="bullet">•</span>
      <span class="text-muted">{{post.createdTime|smart_time}} </span>
      {% if author.badgeTitle|default(null) %}<span class="mll text-danger">({{ dict_text('classroomRoles', author.badgeTitle) }}) </span>{% endif %}
    </div>
    <div class="editor-text">{{ post.content|at(post.ats)|raw }}</div>
    <div class="comment-sns">
      {% include 'TopxiaWebBundle:Thread:post-interaction.html.twig' %}
    </div>
    <div class="thread-subpost-container subcomments clearfix {% if not post.subposts %}hide{% endif %}">
      <div class="thread-subpost-content">
        {{ render(controller('TopxiaWebBundle:Thread:subposts', {threadId: post.threadId|default(0), postId:post.id, less:true})) }}
      </div>
      <div class="thread-subpost-morebar clearfix {% if not post.subposts %}hide{% endif %}">
        {% if service.canAccess('post.create', post) %}
          <button class="btn btn-default btn-xs pull-right js-toggle-subpost-form">我也说一句</button>
        {% endif %}
        <span class="thread-subpost-moretext {% if post.subposts <= 5 %}hide{% endif %}"><span class="text-muted">还有{{ post.subposts - 5 }}条回复，</span><a href="javascript:;" class="js-post-more">点击查看</a></span>
      </div>

      {% if service.canAccess('post.create', post) and app.user %}
        {% if not postReplyUrl is defined %}
          {% set postReplyUrl =  path('thread_post_reply', {threadId:post.threadId, postId:post.id}) %}
        {% endif %}
        <form method="post" action="{{ postReplyUrl }}" class="thread-subpost-form {% if post.subposts %}hide{% endif %}">
          <div class="form-group">
            <div class="controls">
              <textarea class="form-control" name="content" data-display="内容"></textarea>
            </div>
          </div>
          <div class="form-group">
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
            <button type="submit" data-loading-text="正在发表" class="btn btn-primary btn-sm pull-right">发表</button>
          </div>
        </form>
      {% else %}
        <div class="empty">
          你还没有登录，请先<a href="{{ path('login') }}">登录</a>或<a href="{{ path('register') }}">注册</a>！
        </div>
      {% endif %}

    </div>
  </div>
</li>
